//
//  MYRegisterSetPerfectInfoSelectCell.swift
//  MuYing
//
//  Created by tbb on 2019/7/22.
//  Copyright © 2019 TBB. All rights reserved.
//

import UIKit

@objc protocol MYRegisterSetPerfectInfoSelectCellDelegate:NSObjectProtocol {
    
    func gotoSelectAction(_ indexPath:NSIndexPath);
    
}

class MYRegisterSetPerfectInfoSelectCell: MYLoginBaseTextFieldCell {

    @objc weak var delegate:MYRegisterSetPerfectInfoSelectCellDelegate?;
    
    @objc var indexPath:NSIndexPath?
    
    lazy var moreIcon: UIImageView = {
        let moreIcon = UIImageView(image: UIImage(named: "Login_more_select_icon"));
        moreIcon.frame = CGRect(x: 0, y: 0, width: 20, height: 20);
        return moreIcon
    }()
    
    override func layoutSubviews() {
        super.layoutSubviews();
        self.leftIcon.isHidden = true;
        
        self.textField.mas_makeConstraints { (make) in
            make?.bottom.mas_equalTo()(-4);
            make?.left.mas_equalTo()(36);
            make?.right.mas_equalTo()(-36);
            make?.height.mas_equalTo()(21);
        }
        
        self.textField.rightView = self.moreIcon;
        self.textField.rightViewMode = .always;
        
    }
    
    override func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
        
        if let delegate = self.delegate, delegate.responds(to: Selector(("gotoSelectAction:"))), let indexPath = self.indexPath {
            self.delegate?.gotoSelectAction(indexPath)
        }

        return false;
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
